package com.ruoyi.project.simple.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.simple.domain.SplOrderDetailReport;
import com.ruoyi.project.simple.service.ISplOrderDetailReportService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 样品报告Controller
 * 
 * @author zhujj
 * @date 2020-01-09
 */
@RestController
@RequestMapping("/simple/simpleReport")
public class SplOrderDetailReportController extends BaseController
{
    @Autowired
    private ISplOrderDetailReportService splOrderDetailReportService;

    /**
     * 查询样品报告列表
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(SplOrderDetailReport splOrderDetailReport)
    {
        startPage();
        List<SplOrderDetailReport> list = splOrderDetailReportService.selectSplOrderDetailReportList(splOrderDetailReport);
        return getDataTable(list);
    }

    /**
     * 导出样品报告列表
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleReport:export')")
    @Log(title = "样品报告", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SplOrderDetailReport splOrderDetailReport)
    {
        List<SplOrderDetailReport> list = splOrderDetailReportService.selectSplOrderDetailReportList(splOrderDetailReport);
        ExcelUtil<SplOrderDetailReport> util = new ExcelUtil<SplOrderDetailReport>(SplOrderDetailReport.class);
        return util.exportExcel(list, "simpleReport");
    }

    /**
     * 获取样品报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleReport:query')")
    @GetMapping(value = "/{orderDetailReportId}")
    public AjaxResult getInfo(@PathVariable("orderDetailReportId") String orderDetailReportId)
    {
        return AjaxResult.success(splOrderDetailReportService.selectSplOrderDetailReportById(orderDetailReportId));
    }

    /**
     * 新增样品报告
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleReport:add')")
    @Log(title = "样品报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SplOrderDetailReport splOrderDetailReport)
    {
        return toAjax(splOrderDetailReportService.insertSplOrderDetailReport(splOrderDetailReport));
    }

    /**
     * 修改样品报告
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleReport:edit')")
    @Log(title = "样品报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SplOrderDetailReport splOrderDetailReport)
    {
        return toAjax(splOrderDetailReportService.updateSplOrderDetailReport(splOrderDetailReport));
    }

    /**
     * 删除样品报告
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleReport:remove')")
    @Log(title = "样品报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderDetailReportIds}")
    public AjaxResult remove(@PathVariable String[] orderDetailReportIds)
    {
        return toAjax(splOrderDetailReportService.deleteSplOrderDetailReportByIds(orderDetailReportIds));
    }
}
